﻿using Architecture.Api.Application.Commands.SlaughterCorporationCommand;
using Architecture.Domain.Services.Interface;
using Architecture.Domain.TraceabilityManage;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.SlaughterCorporationHandler
{
    public class CorporationCreateCommandHandler : IRequestHandler<SlaughterCorporationCreateCommand, int>
    {
        private readonly ISlaughterService _slaughterService;

        public CorporationCreateCommandHandler(ISlaughterService slaughterService)
        {
            _slaughterService = slaughterService;
        }

        public Task<int> Handle(SlaughterCorporationCreateCommand request, CancellationToken cancellationToken)
        {
            return _slaughterService.AddCorporation(new Corporation()
            {
                //屠宰
                CompanyName = request.CompanyName,
                EstablishmentTime = request.EstablishmentTime,
                ProductionLot = request.ProductionLot,
                CompanyProfile = request.CompanyProfile,
                Province = request.Province,
                City = request.City,
                County = request.County,
            });
        }
    }


}
